<template>
  <div class="share-cell" @click.self="$emit('hide-share-cell')">
    <div class="share-box">
      <div class="share-list">
        <div class="share-item" @click="$router.push('/share/' + id)">
          <div class="icon">
            <img src="@/assets/share-icon/vj.png" alt="" />
          </div>
          <span class="desc">分享图片</span>
        </div>
        <div class="share-item" @click="shareToFriend">
          <div class="icon">
            <img src="@/assets/share-icon/hm.png" alt="" />
          </div>
          <span class="desc">微信</span>
        </div>
        <div class="share-item" @click="shareToCircle">
          <div class="icon">
            <img src="@/assets/share-icon/share-sheet-wechat-moments.png" alt="" />
          </div>
          <span class="desc">朋友圈</span>
        </div>
      </div>
      <div class="close" @click="$emit('hide-share-cell')">取消</div>
    </div>
  </div>
</template>

<script>
export default {
  props: ['id'],
  methods: {
    shareToFriend() {
      this.$toast.loading({
        message: '正在前往微信...'
      })
      setTimeout(() => {
        this.$dialog
          .confirm({
            title: '分享给好友',
            message: '确认要分享给该好友吗？'
          })
          .then(() => {
            this.$toast('分享成功')
            this.$emit('hide-share-cell')
          })
          .catch(() => {
            this.$toast('取消分享')
            this.$emit('hide-share-cell')
          })
      }, 2000)
    },
    shareToCircle() {
      this.$toast.loading({
        message: '正在前往朋友圈...'
      })
      setTimeout(() => {
        this.$dialog
          .confirm({
            title: '分享',
            message: '确认要分享到朋友圈？'
          })
          .then(() => {
            this.$toast('分享成功')
            this.$emit('hide-share-cell')
          })
          .catch(() => {
            this.$toast('取消分享')
            this.$emit('hide-share-cell')
          })
      }, 2000)
    }
  }
}
</script>

<style lang="less" scoped>
.share-cell {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 50;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.7);

  img {
    height: 100%;
    width: 100%;
  }

  .share-box {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    transition: all 0.5s linear;

    .share-list {
      margin-bottom: 5px;
      background-color: #fff;
      display: flex;
      justify-content: space-around;
      align-items: center;
      padding: 15px 0;
      border-top-left-radius: 15px;
      border-top-right-radius: 15px;

      .share-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        .icon {
          height: 40px;
          width: 40px;
        }
        .desc {
          margin-top: 5px;
          color: #333;
          font-size: 12px;
        }
      }
    }
    .close {
      background-color: #fff;
      font-size: 14px;
      text-align: center;
      color: #333;
      line-height: 24px;
      font-weight: 600;
      padding: 10px 0;
    }
  }
}
</style>
